home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / progrmng / flextc.sit / THINK C notes < prev    next >
Encoding:
Text File  |  1990-02-20  |  3.1 KB  |  67 lines  |  [TEXT/KAHL]

  1. Notes on the THINK C version of Flex
  2. Russell S. Finn, 19-FEB-90
  3. Internet: rsfinn@athena.mit.edu, rsfinn@neutron.lcs.mit.edu
  4. CompuServe: 76377,1107
  5. GEnie: RSFINN
  6.  
  7. Flex appears to be covered by a copyright notice from the University of
  8. California, similar to the one covering Berkeley Unix; the Free Software
  9. Foundation is not part of the picture here.  So here is a version
  10. created with THINK C 4.0, along with the source code; as with the
  11. Bison distribution, I am including *all* of the source code I received
  12. with the package.
  13.  
  14. The current version (modification date January 25, 1990) has only the
  15. bare-bones interface provided by the THINK C library routine "ccommand",
  16. which allows the user to type a command line and to redirect the output.
  17. Perhaps someday I may try to implement a "real" user interface; perhaps
  18. not.
  19.  
  20. The only modifications made to the source file are surrounded by "#ifdef
  21. THINK_C"..."#endif"; in theory, then, these sources could be recompiled
  22. on another system if necessary.  These are the actual files modified:
  23. alloca.c, dfa.c, flexdef.h, main.c, misc.c, scan.c, sym.c.  Most of these
  24. changes were minor, and many of them would have been unnecessary if the
  25. original Flex source code had been written for an ANSI-compliant C compiler.
  26. In addition, the file "macutils.c" is completely new; see the discussion
  27. of "MakeRes" below.
  28.  
  29. THINK C users may find it convenient to have the output text files written
  30. by Flex be THINK C documents.  To do this, create a copy of the "ANSI"
  31. project called "ANSI-KAHL", and a copy of the file "fopen.c" called
  32. "fopen-KAHL.c".  In the copy, find the routine "setfiletype", and replace
  33. the lines:
  34.     if (!(oflag & F_BINARY))
  35.         pb.ioFlFndrInfo.fdType = 'TEXT';
  36. with the lines:
  37.     if (!(oflag & F_BINARY)) {
  38.         pb.ioFlFndrInfo.fdType = 'TEXT';
  39.         pb.ioFlFndrInfo.fdCreator = 'KAHL';
  40.         }
  41. Replace "fopen.c" with the new "fopen-KAHL.c", rebuild the new project
  42. "ANSI-KAHL", and use this project in the project file "Flex.╣"
  43. instead of the "ANSI" project.
  44.  
  45. ** The "MakeRes" program
  46.  
  47. The output files created by Flex contain large amounts of preinitialized
  48. static data; the file "scan.c" contained in the Flex.╣ project is one
  49. such file.  However, the Macintosh architecture limits normal applications
  50. to 32K of global data.  In many cases (including Flex), this limit can
  51. be surpassed by the static data generated by Flex.
  52.  
  53. The solution I have implemented for the THINK C version of Flex is to
  54. extract the data tables from the Flex output file, and paste them into
  55. the file "MakeRes.c".  Then, by recompiling and running the program in
  56. the "MakeRes.╣" project (it is not necessary to create an application),
  57. a resource file called "Flex.╣.rsrc" is created in the current directory.
  58. The Flex output file "scan.c" has been modified to load the static data
  59. from the resource fork of the Flex application.  This is done by calling
  60. the "load_table" function, which is defined in the file "macutils.c".
  61.  
  62. In the application for which I needed Flex, the data tables were small
  63. enough that I didn't need to do this.  However, if your application
  64. requires you to do this, simply follow the model of "scan.c"; the MakeRes
  65. project and source code has been included for your use.
  66.  
  67.